package com.trt.contentcenter.feignclient;

import com.trt.contentcenter.domain.dto.user.UserAddBonusDTO;
import com.trt.contentcenter.domain.dto.user.UserDTO;
import com.trt.contentcenter.feignclient.fallback.UserCenterFeignClientFallback;
import com.trt.contentcenter.feignclient.fallbackFactory.UserCenterFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * fallbackFactory 和 fallback二选一,fallbackFactory强大，能拿到异常
 */
//@FeignClient(name = "user-center", configuration = UserCenterFeignConfiguration.class)
//@FeignClient(name = "user-center")
@FeignClient(name = "user-center",
         //fallback = UserCenterFeignClientFallback.class, // 限流降级发生时，定制自己的处理逻辑
        fallbackFactory = UserCenterFeignClientFallbackFactory.class // 获得异常
)
public interface UserCenterFeignClient {

    /**
     * http://user-center/users/{id}
     * @param id
     * @return
     */
//    @GetMapping("/users/{id}")
//    UserDTO findById(@PathVariable Integer id, @RequestHeader("X-Token") String token);

    @GetMapping("/users/{id}")
    UserDTO findById(@PathVariable Integer id);

    @PutMapping("/users/add-bonus")
    UserDTO addBonus(@RequestBody UserAddBonusDTO userAddBonusDTO);


}
